package com.lsc.strategy;

import java.util.*;

public class ReturnStrategy extends BashStrategy {
	
	List<Double> conditionMoney = new ArrayList<Double>(); 		//返利条件
	List<Double> returnMoney = new ArrayList<Double>();		//返利数额

	public ReturnStrategy(ArrayList<List> params) {
		getParam(params);
	}
	

	@Override
	public double getReslt(double money) {
		for(int i =0;i<conditionMoney.size();i++){
			if(money<conditionMoney.get(i))
				continue;
			if(money>=conditionMoney.get(i))
				return money-returnMoney.get(i);
		}
		return money;
	}


	@Override
	void getParam(ArrayList<List> params) {
		for(List<Map<String,Object>> m:params){
			String con =((Map<String,Object>)m.get(0)).get("value").toString(); 
			String re =((Map<String,Object>)m.get(1)).get("value").toString(); 
			conditionMoney.add(Double.parseDouble(con));
			returnMoney.add(Double.parseDouble(re));
		} 
	}

}
